import random


def get_number():
    number = random.randint(1, 100)

    return number


if __name__ == '__main__':
    times = 0
    number = get_number()

    print("猜数字游戏开始！")

    while True:
        my_number = int(input("请输入1~100之间的数字："))
        times += 1

        if my_number < number:
            print("猜小了，请再试一次！")

        elif my_number > number:
            print("猜大了，请再试一次！")

        else:
            print("恭喜你，猜对了！")
            print("你总共猜了", times, "次！")
            break
